package edu.gdkm.dao;


import edu.gdkm.pojo.Student;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;
@Repository
public interface IStudentDao {
    @Select("select * from student where uid=#{uid}")
    public Student getStudentByUid(Integer uid);
    @Select("select * from student where name=#{name} and sno=#{sno}")
    public Student getStudentByNameAndSno(@Param("name") String name,@Param("sno") String sno);
    @Update("update student set uid=#{uid} where sid=#{sid}")
    public Integer updateStudentUidBySid(@Param("sid")Integer sid,@Param("uid")Integer uid);

    @Insert("insert into student value(null,#{name},#{sno},#{major},null,0)")
    @Options(useGeneratedKeys=true, keyProperty="sid", keyColumn="sid")
    public Integer insertStudent(Student student);
    @Update("update student set name=#{name},sno=#{sno},borrowCount =#{borrowCount} where sid=#{sid}")
    public Integer updateStudent(Student student);
    @Delete("delete from student where sid=#{sid}")
    public Integer delStudentBySid(Integer sid);
    @Select("select * from student where sid=#{sid}")
    public Student getStudentBySid(Integer sid);
    @Select("select * from student")
    public List<Student> getStudentList();

}
